import { BaseResponse, PageInfo } from '@/golbal';
import { SearchWordsType } from '@/models/searchWords';
import { request } from '@umijs/max';

/***
 * 获取 搜索推荐结果 search
 */
export async function listSuggestWordsSearch() {
  return request<BaseResponse<PageInfo<SearchWordsType.SuggestWordsSearchVo>>>(
    '/search/list',
    {
      method: 'GET',
      headers: {
        'Content-Type': 'application/json',
      },
      params: {},
    },
  );
}

/**
 * 管理员  查询所有 类型 搜素词
 */
export async function SearchWordsRequest(
  params: SearchWordsType.SuggestWordsSearch,
) {
  return request<BaseResponse<PageInfo<SearchWordsType.SuggestWordsSearchVo>>>(
    '/search/list/all',
    {
      method: 'GET',
      headers: {
        'Content-Type': 'application/json',
      },
      params: params,
    },
  );
}

/**
 * 删除 指定对应的 搜索词
 */
export async function deleteSearchWords(
  params: SearchWordsType.SearchWordsDeleteRequest,
) {
  return request<BaseResponse<PageInfo<SearchWordsType.SuggestWordsSearchVo>>>(
    '/search/delete',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      data: params,
    },
  );
}

/**
 * 修改 指定对应的 搜索词
 */
export async function updateSearchWords(
  params: SearchWordsType.SearchWordsUpdateRequest,
) {
  return request<BaseResponse<number>>('/search/update', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: params,
  });
}

/**
 * 增加 指定推荐
 */
export async function addSearchWords(
  params: SearchWordsType.SearchWordsAddRequest,
) {
  return request<BaseResponse<PageInfo<SearchWordsType.SuggestWordsSearchVo>>>(
    '/search/add',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      data: params,
    },
  );
}
